package org.jaronsource.framework.core.web.taglib;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

public class QueryParamTag extends TagSupport {

	private static final long serialVersionUID = 8077035430436042219L;

	private String name;
	private Object value;

	public String getName() {
		return name;
	}
	
	public void setName( String name ) {
		this.name = name;
	}

	public Object getValue() {
		return value;
	}

	public void setValue( Object value ) {
		this.value = value;
	}

	public int doStartTag() throws JspException {

		QueryTag queryTag = (QueryTag) findAncestorWithClass( this, QueryTag.class );
		if ( queryTag == null ) throw new JspException( "Parent QueryTag not found" );
		queryTag.addParam( name, value );
		return SKIP_BODY;
	}

}